//
//  FKModifyNicknameVC.m
//  HappyTest
//
//  Created by Macbook Pro on 2018/12/29.
//  Copyright © 2018 Macbook Pro. All rights reserved.
//

#import "FKModifyNicknameVC.h"

@interface FKModifyNicknameVC ()

@property (weak, nonatomic) IBOutlet UITextField *nameField;
@property (weak, nonatomic) IBOutlet UIButton *saveBtn;

@end

@implementation FKModifyNicknameVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"昵称";
    self.nameField.text = self.nickname;
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    [self.nameField becomeFirstResponder];
}

- (IBAction)fieldValueChanged:(UITextField *)sender {
    self.saveBtn.enabled = sender.text.length > 0;
}


- (IBAction)saveBtnClicked:(UIButton *)sender
{
    if (self.updateNickname) {
        self.updateNickname(self.nameField.text);
        fkPopVC;
    }
    
    
//    NSMutableDictionary *param = [NSMutableDictionary dictionary];
//    param[@"nickname"] = self.nameField.text;
//    [FKHttpTool postWithSuffix:@"m=Home&c=Mine&a=set_userinfo" param:param success:^(FKBaseResult *result) {
//        if (result.isSuccess) {
//            [SVProgressHUD showSuccessWithStatus:@"修改成功"];
//            if (self.updateNickname) self.updateNickname(self.nameField.text);
//            fkPopVC;
//        }
//    } failure:nil];
}

@end
